package com.mall.shopping.dto;

import com.mall.commons.result.AbstractResponse;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.util.Date;

/**
 * Created by ciggar on 2019/7/23.
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AddCartResponse extends AbstractResponse implements Comparable<AddCartResponse> {

    private Long productId;
    private BigDecimal salePrice;
    private Long productNum;
    private Long limitNum;
    private Boolean checked;
    private String productName;
    private String productImg;
    private Long date;

    public String getBigImg(){
        if (productImg != null && !"".equals(productImg)) {
            String[] strings = productImg.split(",");
            return strings[0];
        }
        return null;

    }


    @Override
    public int compareTo(AddCartResponse o) {
        if (o.getDate() < this.getDate()) {
            return 1;
        } else if (o.getDate() == this.getDate()) {
            return 0;
        } else {

            return -1;
        }

    }
}
